package com.zhugang.week01;

/**
 * @program algorithms
 * @description: divingBoard
 * @author: chanzhugang
 * @create: 2022/04/06 08:22
 */
public class DivingBoard1 {

    public static void main(String[] args) {
        DivingBoard1 board1 = new DivingBoard1();
        int[] result = board1.divingBoard(3, 6, 3);
        for (int i : result) {
            System.out.println(i);
        }
    }

    /**
     * 跳水板： 短板shorter、长板longer，总共k块，返回生成跳水板所有可能长度，从小到达排序
     */
    public int[] divingBoard(int shorter, int longer, int k) {
        if (k == 0) return new int[0];
        if (shorter == longer) return new int[]{k * shorter};
        int[] result = new int[k + 1];
        for (int i = 0; i <= k; i++) {
            result[i] = longer * i + shorter * (k - i);
        }
        return result;
    }
}